define([
  '../common/ReminderPanel'
], function (ReminderPanel) {
  let reminder = new ReminderPanel()              //提示框
  /*
    矢量数据加载
   */
  return function () {
    let americanDataSource, chinaDataSource                //GeoJsonDataSource类型

    //加载并飞向
    $('#loadAmericanStateJson').click(function () {
      reminder.show("加载美国州边界")
      if (americanDataSource === undefined) {
        americanDataSource = Cesium.GeoJsonDataSource.load(
          'data/JsonData/ne_10m_us_states.topojson', {
            stroke: Cesium.Color.HOTPINK,
            fill: Cesium.Color.DEEPSKYBLUE.withAlpha(0.5),
            strokeWidth: 3,
            markerSymbol: '?'
          })
        viewer.dataSources.add(americanDataSource)
      }
      viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(-104, 41, 6000000.0)
      })
    })

    $('#loadChinaProvinceJson').click(function () {
      reminder.show("加载中国省市")
      if (chinaDataSource === undefined) {
        chinaDataSource = Cesium.GeoJsonDataSource.load(
          'data/JsonData/china.json', {
            stroke: Cesium.Color.HOTPINK,
            fill: Cesium.Color.WHITE.withAlpha(0.2),
            strokeWidth: 3,
            markerSymbol: '?'
          })
        viewer.dataSources.add(chinaDataSource)
      }
      viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(116, 40, 6000000.0)
      })
    })

    //清理地图矢量数据，并初始化
    $('#clearAllVectorData').click(function () {
      reminder.show("清除矢量数据")
      viewer.dataSources.removeAll()
      chinaDataSource = undefined
      americanDataSource = undefined
    })
  }
})